import React, { useEffect, useState, useReducer, useContext } from 'react'
import {context1} from './stateBus';



export default function Counter() {
  // 返回值：最新的state和dispatch函数
  //const [state, dispatch] = useReducer(reducer, initialState);
  const { state, dispatch } = useContext(context1);

  return (
    <div>
      Count: {state.count}
      <button onClick={() => dispatch({type: 'increment'})}>+</button>
      <button onClick={() => dispatch({type: 'decrement'})}>-</button>
    </div>
  );
}
